home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <uty25002.h>
-
- //
- // LoadUIBitmap() - load a bitmap resource
- //
- // load a bitmap resource from a resource file, converting all
- // the standard UI colors to the current user specifed ones.
- //
- // this code is designed to load bitmaps used in "gray ui" or
- // "toolbar" code.
- //
- // the bitmap must be a 4bpp windows 3.0 DIB, with the standard
- // VGA 16 colors.
- //
- // the bitmap must be authored with the following colors
- //
- // Window Text Black (index 0)
- // Button Shadow gray (index 7)
- // Button Face lt gray (index 8)
- // Button Highlight white (index 15)
- // Window Color yellow (index 11)
- // Window Frame green (index 10)
- //
- // Example:
- //
- // hbm = LoadUIBitmap(hInstance, "TestBmp",
- // GetSysColor(COLOR_WINDOWTEXT),
- // GetSysColor(COLOR_BTNFACE),
- // GetSysColor(COLOR_BTNSHADOW),
- // GetSysColor(COLOR_BTNHIGHLIGHT),
- // GetSysColor(COLOR_WINDOW),
- // GetSysColor(COLOR_WINDOWFRAME));
- //
- // Author: JimBov, ToddLa
- //
- //
-
- HBITMAP PASCAL LoadUIBitmap(
- HINSTANCE hInstance, // EXE file to load resource from
- LPSTR szName, // name of bitmap resource
- COLORREF rgbText, // color to use for "Button Text"
- COLORREF rgbFace, // color to use for "Button Face"
- COLORREF rgbShadow, // color to use for "Button Shadow"
- COLORREF rgbHighlight, // color to use for "Button Hilight"
- COLORREF rgbWindow, // color to use for "Window Color"
- COLORREF rgbFrame) // color to use for "Window Frame"
- {
- LPBYTE lpb;
- HBITMAP hbm;
- LPBITMAPINFOHEADER lpbi;
- HANDLE h;
- HDC hdc;
- LPDWORD lprgb;
-
- // convert a RGB into a RGBQ
- #define RGBQ(dw) RGB(GetBValue(dw),GetGValue(dw),GetRValue(dw))
-
- h = LoadResource(hInstance,FindResource(hInstance, szName, RT_BITMAP));
-
- lpbi = (LPBITMAPINFOHEADER)LockResource(h);
-
- if (!lpbi)
- return(NULL);
-
- #ifdef NOTNEEDEDFORCTL3D
- if (lpbi->biSize != sizeof(BITMAPINFOHEADER))
- return NULL;
-
- if (lpbi->biBitCount != 4)
- return NULL;
- #endif
-
- lprgb = (LPDWORD)((LPBYTE)lpbi + (int)lpbi->biSize);
- lpb = (LPBYTE)(lprgb + 16);
-
- /*
- lprgb[0] = RGBQ(rgbText); // Black
- lprgb[7] = RGBQ(rgbFace); // lt gray
- lprgb[8] = RGBQ(rgbShadow); // gray
- // lprgb[7] = RGBQ(rgbShadow); // gray
- // lprgb[8] = RGBQ(rgbFace); // lt gray
- lprgb[15] = RGBQ(rgbHighlight); // white
- */
- lprgb[11] = RGBQ(rgbWindow); // yellow
- lprgb[10] = RGBQ(rgbFrame); // green
-
- hdc = GetDC(NULL);
-
- hbm = CreateDIBitmap(hdc, lpbi, CBM_INIT, (LPVOID)lpb,
- (LPBITMAPINFO)lpbi, DIB_RGB_COLORS);
-
- ReleaseDC(NULL, hdc);
- UnlockResource(h);
- FreeResource(h);
-
- return(hbm);
- }
-